import 'package:backend.core/core/domain/entities/api/web/yookassa/api_yookassa_bank_card_info.dart';
import 'package:backend.core/core/domain/entities/web/yookassa/yookassa_bank_card_info.dart';
import 'package:backend.purchases/domain/helpers/api/web/create_api_web_bank_card_type_from_internal_one.dart';

abstract class CreateApiYookassaBankCardInfoFromInternalOne {
  ApiYookassaBankCardInfo call({
    required YookassaBankCardInfo bankCardInfo,
  });
}

class CreateApiYookassaBankCardInfoFromInternalOneImpl
    implements CreateApiYookassaBankCardInfoFromInternalOne {
  const CreateApiYookassaBankCardInfoFromInternalOneImpl({
    required CreateApiWebBankCardTypeFromIntenalOne createApiWebBankCardTypeFromIntenalOne,
  }) : _createApiWebBankCardTypeFromIntenalOne = createApiWebBankCardTypeFromIntenalOne;

  final CreateApiWebBankCardTypeFromIntenalOne _createApiWebBankCardTypeFromIntenalOne;

  @override
  ApiYookassaBankCardInfo call({
    required YookassaBankCardInfo bankCardInfo,
  }) {
    final apiBankCardType = _createApiWebBankCardTypeFromIntenalOne(
      cardType: bankCardInfo.cardType,
    );

    return ApiYookassaBankCardInfo(
      last4: bankCardInfo.last4,
      expirationMonth: bankCardInfo.expirationMonth,
      expirationYear: bankCardInfo.expirationYear,
      cardType: apiBankCardType,
    );
  }
}
